home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1995 March / Macworld CD-ROM (March 1995).cdr / Updaters / AppMaker 1.5.2->1.5.4 / Libraries / THINK / AMClassLibC / CMultiState.cp < prev    next >
Encoding:
Text File  |  1991-08-15  |  1.6 KB  |  56 lines  |  [TEXT/KAHL]

  1. /******************************************************************************
  2.  CMultiState.c
  3.  
  4.                             The MultiState Class
  5.                             
  6.     A standard AppMaker MultiState button. The control's value is incremented
  7.     each time the button is pushed, and loops from the maximum value to the
  8.     minimum value for the control.  The clickCmd, if set, is executed just
  9.     after the value is changed by the superclass.
  10.             
  11.     SUPERCLASS = CAMButton
  12.     
  13.     Copyright © 1991 Bowers Development Corporation. All rights reserved.
  14.  
  15.  ******************************************************************************/
  16.  
  17. #include "CMultiState.h"
  18.  
  19. /******************************************************************************
  20.  DoGoodClick
  21.  
  22.         A MultiState responds to a good click (the mouse being pressed
  23.         and released within the button) by changing its value and then
  24.         calling the inherited method, which will DoCommand (clickCmd)
  25.         if clickCmd is not NULL.
  26.  ******************************************************************************/
  27.  
  28. void    CMultiState::DoGoodClick (short        whichPart)
  29.                                     /* Will always be inButton            */
  30. {
  31.     SetNextState ();
  32.     inherited::DoGoodClick (whichPart);
  33.  
  34. } /* DoGoodClick */
  35.  
  36. /******************************************************************************
  37.  SetNextState
  38.  
  39.         Increments the MultiState's value, wrapping from Max to Min if
  40.         needed.
  41.  ******************************************************************************/
  42.  
  43. void    CMultiState::SetNextState (void)
  44. {
  45.     short        oldValue;
  46.     
  47.     oldValue = GetValue ();
  48.     if (oldValue >= GetMaxValue ()) {
  49.         SetValue (GetMinValue ());
  50.     } else {
  51.         SetValue (oldValue + 1);
  52.     }
  53.  
  54. } /* SetNextState */
  55.  
  56.